﻿using System;
using System.Collections.Generic;

namespace 泛型集合
{
    class Program
    {
        static void Main(string[] args)
        {

            //1.定义两个存放(int)的集合，集合listA {“a”,”b”,”c”,”d”,”e”}  listB {“d”,”e”,”f”,”g”,”h”},
            //将这两个集合去除重复项后合并成一个集合。
            List<string> listA = new List<string>(new string[] { "a","b","c","d","e"});
            List<string> listB = new List<string>(new string[] { "d", "e", "f", "g", "h" });
            Console.WriteLine("合并前");
            Console.WriteLine(string.Join(" ",listA));
            for (int i = 0; i <listB.Count; i++)
            {
                if (listA.Contains(listB[i])==false)
                {
                    listA.Add(listB[i]);
                }
            }
            Console.WriteLine("合并完");
            Console.WriteLine(string.Join(" ",listA));
            Console.WriteLine("-------------------");
            //2.删除偶数
            List<int> listC = new List<int>() { 1,2,3,4,5,6,7,8,9,10};
            for (int i = 0; i <listC.Count; i++)
            {
                if (listC[i]%2==0)
                {
                    listC.Remove(listC[i]);
                }
            }
            Console.WriteLine(string.Join(" ",listC));
        }
    }
}
